#----------------------------
# Name: Beverly Chapman
# Project: Madlibs.py
# Period: 2
# Start Date: 9/17/2013
# Last Revision Date: 9/30/2013
# Version: 1.0.0
#----------------------------
import os

swearFilter = ["ass",
               "bitch",
               "whore",
               "slut",
               "damn",
               "fuck",
               "shit",
               "dick",
               "asshole",
               "wanker",
               "pussy",
               "retard",
               "cunt",
               "nigger",
               "motherfucker",
               "ugly",
               "dumbass",
               "stupid",
               "Dahvie Vanity",
               "Swag",
               "swag"
               "yolo",
               "Yolo",
               "penis"]

def displayStartScreen():
    print "Madlibs"
    raw_input("Press Enter to Continue")
    
def displayEndScreen():
    print "Goodbye"
    raw_input("Press Enter to Exit")

def displaySettings():
    print "Colors: Aqua, Black, Green, Red, Purple, White, Light Blue, Light Aqua, Light Red, Light Purple, Bright White "
    txtColor = getColor("Enter text color: ")
    bgColor = getColor("Enter background color: ")
    if txtColor != bgColor:
        os.system("color "+ txtColor + bgColor)
    
def getColor(prompt):
    colors = ("Aqua", "Black", "Green", "Red", "Purple" "White", "Light Blue", "Light Aqua", "Light Red", "Light Purple", "Bright White")
    opt = ""
    goodColor = False
    while not goodColor:
        opt = raw_input(prompt)
        if opt.capitalize() in colors:
            goodColor = True
    opt = opt.lower()
    if opt == "black":
        color = '0'
    elif opt == "aqua":
        color = '3'
    elif opt == "green":
        color = '2'
    elif opt == "red":
        color = '4'
    elif opt == "purple":
        color = '5'
    elif opt == "white":
        color = '7'
    elif opt == "light blue":
        color = '9'
    elif opt == "light aqua":
        color = 'B'
    elif opt == "light red":
        color = 'C'
    elif opt == "light purple":
        color = 'D'
    elif opt == "bright white":
        color = 'F'
    return color
        
    
def getMenuOption(maxOption):
    option = ""
    goodOption = False
    while not goodOption:
        option = raw_input("Enter Number or Q> ")
        option = option.upper()
        for num in range(1, maxOption+1):
            if option == str(num):
                goodOption = True
        if option == 'Q':
            goodOption = True
        if option == 'T':
            goodOption = True
        if option == 'S':
            goodOption = True 
        if not goodOption:
            print "Please pick a valid option!"
    return option
    
def menu(options):
    print "------Please Select a Story------"
    print " [1] First Day Of School"
    print " [2] Letter To The President"
    print " [3] Locked In a Insane asylum"
    print " [Q] Quit"  
    print " [S] Settings"
    print "----------------------------------"
    option = getMenuOption(options)
    return option
    
def getWord(prompt):
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        if word.lower() not in swearFilter:
            goodWord = True
        else:
            print "Profanity is for the inarticulate, please use appropriate language."
        if not goodWord:
            print "Try again"
    return word
    
def getNumber(prompt, max = "", min = ""):
    num = ""
    goodNum = False
    while not goodNum:
        isNum = True
        num = raw_input(prompt)
        for character in num:
            if character not in "0123456789":
                isNum = False
        if min != "":
            if isNum:
                if float(num) < min:
                    isNum = False
        if max != "":
            if isNum:
                if float(num) > max:
                    isNum = False
        if isNum:
            goodNum = True
        else:
            print "Not a valid number, try again."
    return num
        
def story1():
    name = getWord("Enter a name: ")
    place1 = getWord("Enter a place: ")
    age = getNumber("Enter a number: ")
    feeling = getWord("Enter an emotion ")
    Sname = getWord("Enter a silly name ")
    verb = getWord("Enter a verb ")
    object = getWord("Enter a object ") 
    Pin = getWord("Enter someone in room ") 
    liquid = getWord("Enter a liquid ")
    clothing = getWord("Enter a type of clothing ") 
    pin = getWord("Enter someone else in room ") 
    clothing1 = getWord("Enter a type of clothing. ")  
    story = " Hi my name is "
    story += " " + name + ", "
    story += " I live in " + place1 + " with my parents."
    story += " I am currently " + age + " years old and today is the first day of school. "
    story +=  " I don't really like school but I have heard really good things about Mr." + Sname + "."
    story += " ** " + name + " goes to school. ** "
    story += " I was walking in the hall and I realized I had forgot my " + object + "."
    story += " Crap!! I yelled.. it was a little too loud though because Mr. " + Sname + " came over and asked what was wrong. "
    story += " I told him I forgot my " + object + " ,he said he had an extra and gave it to me. "
    story += " Later that day I had to change because my friend " + Pin + " spilled " + liquid + " all on my " + clothing + "."
    story += " I thought this was a horrible first day but it just got worse. "
    story += " It was the end of the day and my other friend " + pin + " ran up to me and told me that all day I have had a pair of underwear tucked in my " + clothing1 + "."
    story += " I then fell to the floor because today was the most embarrassing day ever. "
    print story
        
def story2():
   name = getWord("Enter your name ")
   Pnoun = getWord("Enter a plural noun ")
   noun = getWord("Enter a noun ")
   verb = getWord("Enter a verb ")    
   Sword = getWord("Enter a silly word ")
   OYO = getWord("Enter an object you own ") 
   Person = getWord("Enter someone's name ")
   
   story = "    Dear Mr.President, "
   story += " My name is " 
   story += " " + name + ". "
   story += " I am writing this letter to inform you that "
   story += " " + Pnoun + " "
   story += " are going to take over the world. "
   story += " There is no need to panic though because I have a solution! The solution is to hit them with a "
   story += " " + noun + ". "
   story += " When you hit them with a " + noun + " they will " + verb + " with fear. "
   story += " If that doesn't work then yell: " + Sword + " They will then randomly combust into flames. "
   story += " You might want to hide your " + OYO + " though because they like to eat them. "
   story += " If you don't believe that" + Pnoun + " are going to take over the world go look out your window. "
   story += " You are probably wondering where they have came from, I believe that " + Person + " did it. "
   story += " Well I have to go I can hear the " + Pnoun + " outside of my house, please take caution they are dangerous."
 
   print story
    
def story3():
    name = getWord("Enter a name ") 
    place = getWord("Enter a place ") 
    bird = getWord("Enter a type of bird ") 
    color = getWord("Enter a color ") 
    object = getWord("Enter a object ") 
    Object = getWord("Enter another object ") 
    Name = getWord("Enter a name ") 
    MI = getWord("Enter a mental illness ") 
    Obj = getWord("Enter another object ") 
    act = getWord("Enter name of a famous actor ") 
    word = getWord("Enter a silly word ") 
    ku = getWord(" Enter a kitchen utensil ") 
    
    story = " Where am I?? I woke up on the floor of an all white room, what is my name?!"
    story += "  Wait! It is coming back to me, my name is " + name + " and I am from " + place + "." 
    story += " I still don't know why I am here..but all I can hear is a woman that is making noises that sounds like a " + bird + "."
    story += " I look around the room and there is nothing but a " + color + " " + object + "." 
    story += " That is the only thing with color in the room, everything else is white." 
    story += " BANG! That was the sound I heard on the door, someone was trying to escape because I heard: Get back here! Then the the screaming from the person suddenly stopped. "
    story += " I have to get out of here so I thought about it..that's it! I looked in the room and saw a " + Object + " ,so I picked it up and threw it at the door and started screaming. "
    story += " A few seconds later nurse " + Name + " came in. "
    story += " I frantically asked her why I was in her and she said: "
    story += "'You have " + MI + ".' "
    story += " So I killed her with a " + Obj + "It was kind of messy but I didn't care I was going to escape."
    story += " I started running but I was careful not to be loud, I then got to the end of the hallway and saw my favorite actor of all time, " + act + "."
    story += " I was covered in blood, " + act + " couldn't see me like this, forget it I don't want to escape anymore, I am obviously in her for a reason."
    story += " I quickly ran over to " + act + " and chloroformed him, I then proceeded by dragging his body to my room. "
    story += " I don't know why I am doing this but it feels good, so I then tie him to my bed and say " + word + "."
    story += " " + act +" "
    story += " then wakes up and tries to scream but I have covered his mouth, now for the fun part. "
    story += " I then take a rusted " + ku + " cut out his heart and eat it. "
    story += " I am probably going to die but that is good because I don't want to live like this, goodbye."
    
    print story
    
def run():
    displayStartScreen()
    choice = ""
    while choice != 'Q':
        choice = menu(3)
        if choice == '1':
            story1()
        elif choice == '2':
            story2()
        elif choice == '3':
            story3()
        elif choice == 'Q':
            displayEndScreen()
            os.system("color 0f")
        elif choice == 'S':
            displaySettings() 
        else: 
            print "Something Awful Ocurred...yell at programmer!"
    exit()
run()